﻿using Abp.Application.Services;
using Abp.Domain.Repositories;
using Abp.Linq.Extensions;
using AbpVueDemo.WeihuDome.LuntaiDataManager.Dto;
using AbpVueDemo.WeihuguanliDemo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AbpVueDemo.WeihuDome.LuntaiDataManager
{
    public class LuntaiDataService : AsyncCrudAppService<LuntaiData, LuntaiDataInputDto, int, PageLuntaiDataRequestDto, LuntaiDataCreateDto, LuntaiDataUpdateDto>, ILuntaiDataService
    {
        public LuntaiDataService(
        IRepository<LuntaiData, int> repository) : base(repository)
        {

        }
        /// <summary>
        /// 自定义分页条件查询, 需要重写父类的CreateFilteredQuery方法,让其进行自定义条件筛选
        /// </summary>
        /// <param name="input">查询条件</param>
        /// <returns></returns>
        protected override IQueryable<LuntaiData> CreateFilteredQuery(PageLuntaiDataRequestDto input)
        {
            return base.CreateFilteredQuery(input)

                 .WhereIf(!string.IsNullOrEmpty(input.chepaihao), c => c.chepaihao.Contains(input.chepaihao))
                  .WhereIf(!string.IsNullOrEmpty(input.pinpai), c => c.pinpai.Contains(input.pinpai))
                   .WhereIf(!string.IsNullOrEmpty(input.guige), c => c.guige.Contains(input.guige))
                  .WhereIf(!string.IsNullOrEmpty(input.shiyongren), c => c.shiyongren.Contains(input.shiyongren))
                   // .WhereIf(input.zhuangtai > 0, c => c.zhuangtai == input.zhuangtai)
                   .WhereIf(input.riqi.HasValue, c => c.riqi == input.riqi);
        }
    }
}
